# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=prometheus-unbound-exporter
_pkgname=unbound_exporter
pkgver=0.3
pkgrel=3
pkgdesc="Prometheus exporter for Unbound statistics"
url="https://github.com/letsencrypt/unbound_exporter"
license="Apache-2.0"
arch="all"
makedepends="go>=1.14"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/letsencrypt/unbound_exporter/archive/v$pkgver.tar.gz
	unbound-exporter.initd
	unbound-exporter.confd
	0001-dont-authenticate-by-default.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"
export GOFLAGS="$GOFLAGS -modcacherw"
options="!check" # no test suite available

build() {
	go build \
		-ldflags "-s -w -X github.com/prometheus/common/version.Version=$pkgver" \
		-v -o unbound_exporter
}

package() {
	install -Dm755 unbound_exporter "$pkgdir"/usr/bin/unbound_exporter

	install -Dm755 "$srcdir"/unbound-exporter.initd "$pkgdir"/etc/init.d/unbound-exporter
	install -Dm644 "$srcdir"/unbound-exporter.confd "$pkgdir"/etc/conf.d/unbound-exporter
}

sha512sums="
ab64dc2a894b07145e030f2cc6f21fe394ef4d3f328164342b9a779c197e9d630c0a881a66d93b316a5dd982463002f4b374de2c140e166e996fb170fa72ae64  unbound_exporter-0.3.tar.gz
99acbb1af5ea1d0f37ec282f8c5dfb884e1d184baa7d5cd0132e63da88defd170fb0db44c762b02a169d93677333231bfb1f7740a401b4e0d64217e8d38927a4  unbound-exporter.initd
2fecc0fdf9da9179ad24c14651efec341fccf3747d4570fe0ca5e1f5db1eb7ec49ce84add28d2804c03c95acd9762a660dfe5577fe26265ef35a82fa9c455aad  unbound-exporter.confd
7f806a9a19da38e790c978c411f9f37e1ddda7e74b37b3c691111fe86c79957d9704f1b4ee15d25da54b749e2c7322c6833087618455d05be7768452f4522d50  0001-dont-authenticate-by-default.patch
"
